package com.whut.transportation.overweight;

import android.app.TabActivity;
import android.content.Intent;
import android.os.Bundle;
import android.view.Window;
import android.widget.RadioGroup;
import android.widget.TabHost;
import android.widget.RadioGroup.OnCheckedChangeListener;

import com.whut.transportation.R;
import com.whut.transportation.utils.AppManager;



@SuppressWarnings("deprecation")
public class OWHomeActivity extends TabActivity {

	private RadioGroup mTabButtonGroup;
	private TabHost mTabHost;
	
	public static final String TAB_MAIN = "MAIN_ACTIVITY";
	public static final String TAB_SEARCH = "SEARCH_ACTIVITY";
	public static final String TAB_CATEGORY = "CATEGORY_ACTIVITY";
	public static final String TAB_PERSONAL = "PERSONAL_ACTIVITY";
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		requestWindowFeature(Window.FEATURE_NO_TITLE);
		AppManager.getAppManager().addActivity(this);
		setContentView(R.layout.activity_ow_home);
		findViewById();
		initView();
	}
	private void findViewById() {
		mTabButtonGroup = (RadioGroup) findViewById(R.id.home_radio_button_group);
	}
	private void initView() {
		mTabHost = getTabHost();
		
		Intent i_main = new Intent(this, OWMainActivity.class);
		//Intent i_category = new Intent(this, OWCategoryActivity.class);
		Intent i_search = new Intent(this, OWSearchActivity.class);
		Intent i_personal = new Intent(this, OWPersonalActivity.class);
		
		mTabHost.addTab(mTabHost.newTabSpec(TAB_MAIN).setIndicator(TAB_MAIN)
				.setContent(i_main));
		//mTabHost.addTab(mTabHost.newTabSpec(TAB_CATEGORY).setIndicator(TAB_CATEGORY).setContent(i_category));
		mTabHost.addTab(mTabHost.newTabSpec(TAB_SEARCH)
				.setIndicator(TAB_SEARCH).setContent(i_search));
		mTabHost.addTab(mTabHost.newTabSpec(TAB_PERSONAL)
				.setIndicator(TAB_PERSONAL).setContent(i_personal));
		mTabHost.setCurrentTabByTag(TAB_MAIN);
		mTabButtonGroup.setOnCheckedChangeListener(new OnCheckedChangeListener() {
			public void onCheckedChanged(RadioGroup group, int checkedId) {
				switch (checkedId) {
				case R.id.home_tab_main:
					mTabHost.setCurrentTabByTag(TAB_MAIN);
					break;
				case R.id.home_tab_search:
					mTabHost.setCurrentTabByTag(TAB_SEARCH);
					break;
				/*case R.id.home_tab_category:
					mTabHost.setCurrentTabByTag(TAB_CATEGORY);
					break;*/
				case R.id.home_tab_personal:
					mTabHost.setCurrentTabByTag(TAB_PERSONAL);
					break;
				default:
					break;
				}
			}
		});
		
	}
}
